package com.xkcyy.study.jvm.bytecode.lambda;

import com.xkcyy.study.jvm.bytecode.interfaces.InterfaceTest;

import java.lang.invoke.CallSite;
import java.lang.invoke.LambdaMetafactory;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.util.function.Function;
import java.util.function.Predicate;

/**
 * LambdaTest
 *
 * @author yuand
 * @date 2021/8/23
 **/
public class LambdaTest {
    private static int value = 123;
    private static Runnable pred = () -> {
        System.out.println();
    };
    private static Runnable pred2 = InterfaceTest::test;
//    private static Predicate<String> pred2 = x -> x.startsWith("1");
//    private static boolean ss = pred.test("aaa");
    // 1. x->x.isEmpty() 会生成一个函数
    // 2. pred = 会被变为 invokeDynamic

    //    public Runnable test1() {
//        Runnable runnable = () -> {
//
//            System.out.println("");
//        };
//        return runnable;
//    }
//    static class InnerTest {
//    }

    static {
//        CallSite metafactory = LambdaMetafactory.metafactory(MethodHandles.lookup(), );

    }

//    public static void main(String[] args) throws ClassNotFoundException {
//        Class<?> aClass = pred.getClass();
//
//
////        String className = "java.lang.invoke.MethodHandles$Lookup";
////        Class<?> aClass = Class.forName(className);
////        BootstrapMethodError
//
////        MethodHandle methodHandle = MethodHandles.lookup().findStatic();
////        methodHandle.in
////        MethodHandles.lookup().findStatic().invokeWithArguments()
//    }
}
